﻿using System;
using System.Configuration;
namespace DBUtility
{
    
    public class PubConstant
    {

        public string ConnectionString { set; get; }
        /// <summary>
        /// get the ConnectionString from system.ini
        /// </summary>
        /// <returns></returns>
        public static string GetConnectionString()
        {
            IniFiles myini = new IniFiles(System.Environment.CurrentDirectory + "\\system.ini");

            string serverName = myini.ReadString("DBCONFIG", "SERVERNAME", "127.0.0.1");
            string dbName = myini.ReadString("DBCONFIG", "DatBaseName", "personallocationsystem");
            string uid = myini.ReadString("DBCONFIG", "UserID", "root");
            string pwd = myini.ReadString("DBCONFIG", "PassWord", "123456");
            //BtsServer.DbName = DbName;

            string connectStr = "Server=" + serverName + ";Database=" + dbName + ";port=3306;Uid=" + uid + ";Connection Timeout=8;charset=utf8;Pwd=" + pwd;
            return connectStr;
        }

        public static string GetConnectionString(string dataBaseName)
        {
            IniFiles myini = new IniFiles(System.Environment.CurrentDirectory + "\\system.ini");
            string serverName = myini.ReadString("DBCONFIG", "SERVERNAME", "127.0.0.1");
            string dbName = dataBaseName;
            string uid = myini.ReadString("DBCONFIG", "UserID", "root");
            string pwd = myini.ReadString("DBCONFIG", "PassWord", "123456");
            //BtsServer.DbName = DbName;  Pooling=false;

            string connectStr = "Server=" + serverName + ";Database=" + dbName + ";port=3306;Uid=" + uid + ";Connection Timeout=8;charset=utf8;Pwd=" + pwd;
            return connectStr;
        }


    }
}
